package com.wx.adapter.http.wx.ma;

import com.wx.adapter.http.wx.ma.domain.dto.MiniProgramLoginTokenDTO;
import com.wx.adapter.http.wx.ma.domain.dto.MiniprogramPhoneDTO;
import com.wx.adapter.http.wx.ma.domain.req.Code2PhoneReq;
import com.wx.adapter.http.wx.ma.domain.req.StableTokenReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * wx_back_end
 *
 * @Auther: cheng.tang
 * @Date: 2023/2/10 8:36 PM
 * @Description:
 */
@FeignClient(name = "MiniProgramUserFeign", url = "https://api.weixin.qq.com")
public interface MiniProgramUserFeign {

    @PostMapping("/wxa/business/getuserphonenumber")
    MiniprogramPhoneDTO getuserphonenumber(@RequestParam("access_token") String access_token, @RequestBody Code2PhoneReq code2PhoneReq);

    @GetMapping("/cgi-bin/token")
    MiniProgramLoginTokenDTO cgiBinToken(@RequestParam("grant_type") String grant_type,
                                         @RequestParam("appid") String appid,
                                         @RequestParam("secret") String secret);

    @PostMapping("/cgi-bin/stable_token")
    MiniProgramLoginTokenDTO getStableAccessToken(@RequestBody StableTokenReq stableTokenReq);

    /**
     * 这个接口返回的content-type是text/plain
     *
     * @param appid
     * @param secret
     * @param js_code
     * @param grant_type
     * @return
     */
    @GetMapping("/sns/jscode2session")
    String snsJscode2session(
            @RequestParam("appid") String appid,
            @RequestParam("secret") String secret,
            @RequestParam("js_code") String js_code,
            @RequestParam("grant_type") String grant_type);

}
